%{
#include <stdio.h>
#include <string.h>
#include "y.tab.h"
#include "tree.h"
int lineno = 1;
%}

%%
Num|Num(2|4|8)            { 
        int type=atoi(&yytext[3]);
        if(type==2)
            return NUM2;
        else if(type==4)
            return NUM4;
        else if(type==8)
            return NUM8;
        else
            return NUM;
    }
Bit(8|16|32|64)        { 
        int type=atoi(&yytext[3]);
        if(type==8)
            return BIT8;
        else if(type==16)
            return BIT16;
        else if(type==32)
            return BIT32;
        else
            return BIT64;
    }
Str         {   }

DICTS       { return DICTS;}
STRUCT      { return STRUCT;}
BOOL        { return BOOLEAN;}

Integer     { return INTEGER; }
Float       { return FLOAT; }
Pointer     { return POINTER; }

FUNC        { return FUNC;}
DO          return DO;
WHILE       return WHILE;
LOOP        return LOOP;
FOR         return FOR;
BREAK       return BREAK;
CONTINUE    return CONTINUE;
IF          return IF;
ELSE        return ELSE;
ELSEIF      return ELSEIF;
SWITCH      return SWITCH;
CASE        return CASE;
DEFAULT     return DEFAULT;
RETURN      return RETURN;
THEN        return THEN;
END         return END;
AND         return AND;
OR          return OR;

"=="    return EQ;
"!="    return NEQ;
"==="   return IDENTITY;
"!=="   return NIDENTITY;
"<"     return LT;
">"     return GT;
"<="    return LE;
">="    return GE;
"::"    return TO;

[a-zA-Z_][A-Za-z_0-9]*   {
    yylval.p_str = strdup(yytext);
    return NAME;
}




[0-9]+     {
    yylval.p_double = Str2Double(yytext);
    return INT;
}

[0-9]+\.[0-9]+  { 
    yylval.p_double = Str2Double(yytext);
    return DECIMAL;
}

\"[^\"]*\"  { 
    char *str = yytext+1;
    str[yyleng-2] = '\0';
    yylval.p_str = strdup(str);
    return STRING; 
}
\n      lineno++;
[ \t\r]+    ;

"--".*      ;
. 		return yytext[0];
        
%%